<?php
header("Content-type: text/html; charset=utf-8");
$a_array = array(
                    'name'=>'张三',
                    'hp'=>100,
                );
$b_array = array(
                    'name'=>'李四',
                    'hp'=>100,
                );
function fight($attacker, $defender){
    static $log = array();
    $hit_point = mt_rand(20, 50);
    $defender['hp'] -= $hit_point;
    if($defender['hp'] <=0){
        $log[] = array(
                            $attacker['name'].'攻击'.$defender['name'].'造成了'.$hit_point.'点伤害'.'战斗结束',
                       );
        return $log;
    }
    $log[] = array(
                        $attacker['name'].'攻击'.$defender['name'].'造成了'.$hit_point.'点伤害'.'剩余'.$defender['hp'].'血量',
                  );
    return fight($defender, $attacker);
}
$result = fight($a_array, $b_array);
//1111122222222222222
//echo '<pre>';
//print_r($result);
//echo '</pre>';
//3333333344444444
